﻿using PmSoft;

namespace Modules.System.Settings
{
    /// <summary>
    /// 设置管理器
    /// </summary>
    /// <typeparam name="TSettingsEntity"></typeparam>
    public class SettingManager<TSettingsEntity> where TSettingsEntity : class, IEntity, new()
    {
        private readonly SettingRepository<TSettingsEntity> repository;

        public SettingManager(SettingRepository<TSettingsEntity> repository)
        {
            this.repository = repository;
        }

        public static SettingManager<TSettingsEntity> Instance
        {
            get
            {
                return ServiceAccessor.GetScoped<SettingManager<TSettingsEntity>>();
            }
        }

        public TSettingsEntity Get()
        {
            return repository.Get();
        }

        public void Save(TSettingsEntity settings)
        {
            repository.Save(settings);
        }
    }
}